package com.shenmazong.core;

/**
 * @program: server-java-demo
 * @description: 单例模式：懒汉，线程不安全
 * @author: 亮子说编程
 * @create: 2020-10-15 09:06
 **/
public class Singleton01 {
    private static Singleton01 instance;

    private Singleton01() {
    }

    public static Singleton01 getInstance() {
        if (instance == null) {
            instance = new Singleton01();
        }
        return instance;
    }

    private static Class getClass(String classname)
            throws ClassNotFoundException {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

        if(classLoader == null) {
            classLoader = Singleton01.class.getClassLoader();
        }

        return (classLoader.loadClass(classname));
    }

}
